package com.yida.gwj.report.service.impl;

import com.yida.gwj.report.annotation.CalculateRateLog;
import com.yida.gwj.report.domain.GwjCalculateRateLog;
import com.yida.gwj.report.mapper.GwjCalculateRateAreaMapper;
import com.yida.gwj.report.mapper.GwjCalculateRateCommunityMapper;
import com.yida.gwj.report.mapper.GwjCalculateRateHouseMapper;
import com.yida.gwj.report.service.IGwjCalculateRateLogService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: PPV
 * @Date: 2023-03-17
 */
@Service
public class GwjCalculateRateLogServiceImpl implements IGwjCalculateRateLogService {

    @Resource
    private GwjCalculateRateCommunityMapper communityMapper;

    @Resource
    private GwjCalculateRateAreaMapper areaMapper;

    @Resource
    private GwjCalculateRateHouseMapper houseMapper;

    @Override
    public void saveLog(GwjCalculateRateLog log, CalculateRateLog.LogType logType) {
        switch (logType) {
            case AREA:
                areaMapper.insert(log);
                break;
            case COMMUNITY:
                communityMapper.insert(log);
                break;
            case HOUSE:
                houseMapper.insert(log);
            default:
                break;
        }
    }

    @Override
    public List<GwjCalculateRateLog> listCommunityLogs(Long areaId, String calculateFlag) {
        return communityMapper.listLogs(areaId, calculateFlag);
    }

    @Override
    public List<GwjCalculateRateLog> listHouseLogs(Long areaId, String calculateFlag) {
        return houseMapper.listLogs(areaId, calculateFlag);
    }

    @Override
    public List<GwjCalculateRateLog> listHouseLogs4Community(Long communityId, String calculateFlag) {
        return houseMapper.listLogs4Community(communityId,calculateFlag);
    }
}
